<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<script>
	function after_switchNode(id, tab_index) {
		var current_panel = $.pdialog.getCurrent() && $.pdialog.getCurrent().filter(":visible").length > 0 ? $.pdialog.getCurrent() : navTab.getCurrentPanel();
		$("#proj_stat", current_panel).find("option[value='" + id + "']").attr("selected", "true");
		$("#currentindex", current_panel).val(tab_index);
	}
</script>

<form id="pagerForm" method="post" action="app/project/audit.do?action=pageProjectAuditIndex&phase=${phase}">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
	<input type="hidden" id="currentindex" name="currentindex" value="${currentindex ne null ? currentindex : 0}" />
</form>

<!-- SearchBar -->
<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="app/project/audit.do?action=pageProjectAuditIndex&phase=${phase}" method="post" id="searchForm" rel="pagerForm">
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>
						<label>项目编号：</label>
						<input type="text" name="projectNo" rel="pagerForm" value="${projectNo ne null ? projectNo : ''}" />
					</td>
					<td>
						<label>项目名称：</label>
						<input type="text" name="projectName" rel="pagerForm" value="${formEntity ne null ? formEntity.projectName : ''}" />
					</td>
					<td>
						<label>项目负责人：</label>
						<input id="projectMgrId" name="mgr.id" value="${formEntity ne null && formEntity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
						<input id="projectMgr" type="text" name="mgr.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectManager ne null ? formEntity.projectManager.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="mgr" />
					</td>
				</tr>
				<tr>
					<td>
						<label>行业类别：</label>
						<select class="combox required" error_message="请选择`项目所属行业`" name="projectTypeId" id="proj_track_aduit_type_${phase}">
							<option value="">请选择一个行业</option>
							<logic:present name="dictInds">
								<logic:iterate name="dictInds" id="dict">
									<option value="${dict.id}" ${projectTypeId ne null && projectTypeId eq dict.id ? 'selected="true"' : ''}>${dict.dictKey}</option>
								</logic:iterate>
							</logic:present>
						</select>
					</td>
					<c:if test="${phase ne 'conference_preaudit'}">
					<td>
						<label>项目进展：</label>
						<select id="proj_stat" style="margin-top: 2px;" ${phase ne null ? 'disabled' : ''}>
							<c:choose>
								<c:when test="${phase eq 'trial'}">
									<option value="2" selected>初审</option>
								</c:when>
								<c:when test="${phase eq 'review'}">
									<option value="2" selected>复审</option>
								</c:when>
								<c:when test="${phase eq 'conference'}">
									<logic:present name="nodesForConference">
										<logic:iterate name="nodesForConference" id="node">
											<option value="${node.id}">${node.nodeTitle}</option>
										</logic:iterate>
									</logic:present>
								</c:when>
							</c:choose>
						</select>
					</td>
					</c:if>
				</tr>
				<input type="hidden" name="phase" value="${phase}" />
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				</ul>
			</div>
		</div>
		<input type="hidden" name="currentindex" id="currentindex" value="${currentindex ne null ? currentindex : 0}" />
	</form>
</div>

<!-- Body -->
<div class="unitBox" id="jbsxBox">
	<div class="pageContent">
		<c:choose>
			<c:when test="${phase eq 'conference_preaudit'}">
				<!-- Tabs -->
				<div class="tabs" currentindex="${currentindex ne null ? currentindex : 0}" eventtype="click">
					<logic:present name="nodesForConferencePreAudit">
						<div class="tabsHeader">
							<div class="tabsHeaderContent">
								<ul>
									<logic:iterate name="nodesForConferencePreAudit" id="node" indexId="idx">
										<c:if test="${tm:inRange('ROLE_SUPER,ROLE_ADMIN', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',') || sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey eq node.toAuditRole.roleKey}">
											<li class="selected"><a href="app/project/track.do?action=actionLoadProjectConference&cid=${node.id}&module=${module}" class="j-ajax" callback="after_switchNode('${node.id}', ${idx})" paramRef="pagerForm, searchForm"><span>${node.nodeTitle}<c:if test="${node.auditNum ne null && node.auditNum gt 0}">(${node.auditNum})</c:if></span></a></li>
										</c:if>
									</logic:iterate>
								</ul>
							</div>
						</div>
						<div class="tabsContent" style="height:auto;">
							<logic:iterate name="nodesForConferencePreAudit" id="node">
								<div inited="1000" style="display: none;"></div>
							</logic:iterate>
						</div>
					</logic:present>
					<div class="tabsFooter">
						<div class="tabsFooterContent"></div>
					</div>
				</div>
			</c:when>
			<c:when test="${phase eq 'conference'}">
				<!-- Tabs -->
				<div class="tabs" currentindex="${currentindex ne null ? currentindex : 0}" eventtype="click">
					<logic:present name="nodesForConference">
						<div class="tabsHeader">
							<div class="tabsHeaderContent">
								<ul>
									<logic:iterate name="nodesForConference" id="node" indexId="idx">
										<li class="selected"><a href="app/project/track.do?action=actionLoadProjectByProcess&tid=${node.id}&module=${module}" class="j-ajax" callback="after_switchNode('${node.id}', ${idx})" paramRef="pagerForm, searchForm"><span>${node.nodeTitle}<c:if test="${node.auditNum ne null && node.auditNum gt 0}">(${node.auditNum})</c:if></span></a></li>
									</logic:iterate>
								</ul>
							</div>
						</div>
						<div class="tabsContent" style="height:auto;">
							<logic:iterate name="nodesForConference" id="node">
								<div inited="1000" style="display: none;"></div>
							</logic:iterate>
						</div>
					</logic:present>
					<div class="tabsFooter">
						<div class="tabsFooterContent"></div>
					</div>
				</div>
			</c:when>
			<c:otherwise>
				<%@ include file="../../public/datagrid/dataGridProject.jsp" %>
			</c:otherwise>
		</c:choose>
	</div>
</div>
